package ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.generateRFCPanel.generateRFCSubs.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JOptionPane;

import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.generateRFCPanel.GenerateRFCPanel;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.generateRFCPanel.generateRFCSubs.GenRFCFunctionPanel;

public class CancelRFCButtonListener  implements ActionListener{
	
	private GenRFCFunctionPanel functionPanel;
	private GenerateRFCPanel generateRFCPanel;
	
	public CancelRFCButtonListener(GenRFCFunctionPanel functionPanel, GenerateRFCPanel generateRFCPanel){
		
		this.functionPanel = functionPanel;
		this.generateRFCPanel = generateRFCPanel;
	}

	@Override
	public void actionPerformed(ActionEvent e) {


		int answer = JOptionPane.showConfirmDialog(generateRFCPanel.getDatainputPanel(), "Alle nicht gespeicherten Informationen gehen verloren");
		if (answer==0) {
			
			functionPanel.getBu_newRFC().setEnabled(true);
			functionPanel.getBu_editButton().setEnabled(true);
			functionPanel.getBu_cancel().setEnabled(false);
			functionPanel.getBu_sendRFC().setEnabled(false);
			functionPanel.getBu_save().setEnabled(false);
			functionPanel.getBu_deleteRFC().setEnabled(false);
			
			generateRFCPanel.setVisible(false);
			generateRFCPanel.getDatainputPanel().removeAllPanles();
			generateRFCPanel.setVisible(true);
			
		}
	}

}
